package us.gaaoc.framework.webapp.backingbeans.admin;

 
import java.util.List;
import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import org.apache.log4j.Logger; 

import us.gaaoc.framework.businessmodel.Filing;
import us.gaaoc.framework.dao.ModelFacade;
import us.gaaoc.framework.dao.ModelFacadeHibernate; 
import us.gaaoc.framework.webapp.backingbeans.BaseBackingBean;

/**
 * 
 * @author hea
 * @date Apr 18, 2006
 * @version: GAJE 1.5
 *
 */
public class NewFilingPage  extends BaseBackingBean{

	/**
	 * Properties
	 */
  	private DataModel dataTableList;
	private Logger LOG = Logger.getLogger(NewFilingPage.class);

	/**
	 * Constructor
	 *
	 */
	public NewFilingPage(){
		dataTableList = new ListDataModel();
		this.loadData();
	}		 

	/**
	 * Getter for property dataTableList
	 * @return dataTableList
	 */
	public DataModel getDataTableList() {
		return dataTableList;
	}

	/**
	 * Setter for property dataTableList
	 * @param dataTableList
	 */
	public void setDataTableList(DataModel dataTableList) {
		this.dataTableList = dataTableList;
	}
	
	/**
	 * This method loads the data from the database for status='Received'
	 *
	 */
	private void loadData(){
		String courtUuid = (String)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("courtUuid");
        //   status = received (1)
		List<Filing> newFilings = this.getModelFacade().findCaseFilingsByStatus(1, courtUuid);			
		dataTableList.setWrappedData(newFilings);
	}

	/**
	 * This method navigates user to the Case Details Page
	 * @return String
	 */
	@SuppressWarnings("unchecked")
	public String gotoCaseDetailPage(){
		Map sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
	 	Map requestMap = this.getFacesContext().getExternalContext().getRequestParameterMap();
	 	String caseUuid = ((String) requestMap.get("caseUuid"));
	 	sessionMap.put("caseUuid", caseUuid);
	 	sessionMap.put("from", "NewFilingPage");
		return "caseDetailsPage";
	}
	
	/**
	 * This method navigates user to the previous page
	 * @return String
	 */
	public String back(){
		return "back";
	}
}

